<!-- wyf 2022-3-14 -->
<template>
  <a-dropdown
    v-model:visible="visible1"
    :disabled="disabled"
    :get-popup-container="getPopupContainer"
    :overlay-class-name="overlayClassName"
    :overlay-style="overlayStyle"
    :placement="placement"
    :trigger="trigger"
  >
    <template v-if="$slots.overlay" #overlay>
      <slot name="overlay" />
    </template>
    <slot />
  </a-dropdown>
</template>

<script>
import { defineComponent, computed } from 'vue'
import { Dropdown } from 'ant-design-vue'
export default defineComponent({
  name: 'ZDropdown',
  components: {
    ADropdown: Dropdown
  },
  props: {
    getPopupContainer: {
      type: Function,
      default: undefined
    },
    disabled: {
      type: Boolean,
      default: false
    },
    overlayClassName: {
      type: String,
      default: undefined
    },
    overlayStyle: {
      type: Object,
      default: undefined
    },
    placement: {
      type: String,
      default: 'bottomLeft'
    },
    trigger: {
      type: Array,
      default() {
        return ['hover']
      }
    },
    visible: {
      type: Boolean,
      default: undefined
    }
  },
  setup(props, _ref) {
    const visible1 = computed({
      get() {
        return props.visible
      },
      set(val) {
        _ref.emit('update:visible', val)
      }
    })
    return {
      visible1
    }
  }
})
</script>
